using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using converter.template;
using converter.template.item;

namespace converter
{
	// Report Items parsing methods. This includes Body, PageHeader, and PageFooter.
	public sealed partial class RdlFile
	{
        // Find the body part of the report and parse it.
        private void ParseBody(XDocument xdoc, XNamespace xmlns, Template template)
        {
            // Find the body element.
            XElement body = null;
            IEnumerable<XElement> elements = xdoc.Root.Descendants(xmlns + "Body");
            if (elements != null)
                body = elements.Single();
            if (body == null)
                return;

            // Find the ReportsItem element in the body.
            XElement reportItems = body.Element(xmlns + "ReportItems");
            if (reportItems == null)
                return;

            // Parse the body items.
            foreach (XElement item in reportItems.Elements())
                ParseReportItem(template.Body, item);
        }
    }
}